home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / cperf-21.lha / cperf-2.1 / tests / test.c < prev   
C/C++ Source or Header  |  1989-11-01  |  644b  |  33 lines

  1. /*
  2.    Tests the generated perfect has function.
  3.    The -v option prints diagnostics as to whether a word is in 
  4.    the set or not.  Without -v the program is useful for timing.
  5. */ 
  6.   
  7. #include <stdio.h>
  8.  
  9. #define MAX_LEN 80
  10.  
  11. #ifdef __STDC__
  12. int in_word_set (char *, unsigned int);
  13. int 
  14. main (int argc, char *argv[])
  15. #else
  16. int 
  17. main (argc, argv) 
  18.      int   argc;
  19.      char *argv[];
  20. #endif
  21. {
  22.   int  verbose = argc > 1 ? 1 : 0;
  23.   char buf[MAX_LEN];
  24.  
  25.   while (gets (buf)) 
  26.     if (in_word_set (buf, strlen (buf)) && verbose) 
  27.       printf ("in word set %s\n", buf);
  28.     else if (verbose) 
  29.       printf ("NOT in word set %s\n", buf);
  30.  
  31.   return 0;
  32. }
  33.